<?php
require_once 'pages/TMSFrontPage.inc';
require_once 'security/captcha.inc';

class TMSFrontAuthPage extends TMSFrontPage {
	public function NeedsCaptcha(){
		return $this->Application()->Session()->Get('first_login_failed');
	}
	
	public function http_Login($login,$pwd,$captcha = null){		
		if ($this->NeedsCaptcha())
			$this->checkCaptcha($captcha);
		
		if ($this->service->Acl->Login($login,$pwd)){
			$this->Application()->Session()->Set('first_login_failed', null);
			$this->Application()->Redirect($this->Application()->Url());
		} else {
			$this->Application()->Session()->Set('first_login_failed', true);
			throw new TExposableException('Логин или пароль введен неверно!');
		}	
	}
}
